<template>
  <!-- 报价信息 -->
  <div id="quoteDetail">
    <el-form :model="form" label-width="100">
      <el-form-item label="报价单号:" style="width: 100%">
        <p>{{ form.quotesNumber }}</p>
      </el-form-item>
      <el-form-item label="报价名称:">
        <p>{{ form.quotesName }}</p>
      </el-form-item>
      <el-form-item label="客户名称:" class="contractItem">
        <p v-if="form.customerName" @click="toCustomerDetail" class="click">
          {{ form.customerName }}
        </p>
        <!-- <el-button
          type="primary"
          size="small"
          @click="addContract(form)"
          v-if="!form.customerName"
          >添加合同</el-button
        > -->
      </el-form-item>
      <!-- <el-form-item label="总金额:">
         优惠之前金额
        <p>{{ form.price + form.discountMoney }}元</p>
      </el-form-item> -->
      <el-form-item label="付款方式:">
        <p>{{ form.payDescription }}</p>
      </el-form-item>
      <el-form-item label="交货日期:">
        <p>{{ form.deliveryTime ? form.deliveryTime : 0 }}天之后</p>
      </el-form-item>
      <el-form-item label="验收标准:">
        <p>{{ form.checkRule }}</p>
      </el-form-item>
      <!-- <el-form-item v-if="form.isDiscount == 1" label="优惠金额:">
        <p>{{ form.discountMoney ? form.discountMoney : 0 }}元</p>
      </el-form-item> -->
      <el-form-item label="描述:">
        <p>{{ form.description }}</p>
      </el-form-item>
      <el-form-item label="报价人:">
        <p>{{ form.adminName }}</p>
      </el-form-item>
      <el-form-item label="审核状态:" v-if="isReloadData" style="width: 100%">
        <p v-if="form.status == 0" style="color: #e6a23c">待审核</p>
        <p v-if="form.status == 1" style="color: #67c23a">通过</p>
        <p v-if="form.status == 2" style="color: #f56c6c">未通过</p>
        <p v-if="form.status == 3" style="color: #ff9b31">审核中</p>
      </el-form-item>
      <el-form-item label="创建时间:">
        <p>{{ form.createTime }}</p>
      </el-form-item>
      <!-- <el-form-item label="修改时间:" v-if="form.updateTime">
        <p>{{ form.updateTime }}</p>
      </el-form-item> -->
    </el-form>
    <el-button
      type="primary"
      style="margin-left: 30px"
      @click="printPreview"
      v-if="$route.query.id"
      >打印预览</el-button
    >
    <print-dom ref="printDom" v-show="false" id="printDom"></print-dom>
  </div>
</template>
<script>
import print from '@/utils/print'
import printDom from '../../components/printDom.vue'
export default {
  name: 'quoteDetail',
  data () {
    return {
      // form: {},
      isReloadData: true//局部刷新标识
    }
  },
  components: {
    printDom
  },
  mounted () {

  },
  props: {
    form: {
      type: Object,
      required: true,
      default: () => {
        return {}
      }
    }
  },
  methods: {
    //打印预览
    printPreview () {
      this.getDetail()
    },

    // 获取报价详情
    async getDetail () {
      let { data: configData } = await this.$API.contract.contractConfig.getConfigDetail.post({ id: 1 })
      // let { data } = await this.$API.contract.quoteManagement.getQuoteDetailById.post({ id })
      this.$refs.printDom.provideForm = this.form
      console.log(this.form)
      this.$refs.printDom.needForm = configData
      this.$nextTick(() => {
        let dom = document.querySelector('#printDom')
        let clone = dom.cloneNode(true)
        clone.style.display = 'block'
        print(clone)
      })
    },

    toCustomerDetail () {
      this.$router.push({
        path: '/customer/customerManagement/customerDetail',
        query: {
          id: this.form.customerId
        }
      })
    },

    relodPart () {
      this.isReloadData = false
      this.$nextTick(() => {
        this.isReloadData = true
      })
    }

  }
}

</script>
<style lang='scss' scoped>
.contractItem {
  :deep(.el-form-item__content) {
    align-items: center;
  }
}
</style>